﻿using System.Net;
using System.Resources;
using System.Windows.Markup;
using JetBrains.Annotations;

#region Honorbuddy

using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.Routines;
using Styx.Helpers;
using Styx.Pathing;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using CommonBehaviors.Actions;
using Action = Styx.TreeSharp.Action;
#endregion

#region System
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
#endregion

namespace Simcraft
{
    public partial class SimcraftImpl 
    {


        public static Composite PaladinBuffs()
        {
            return new PrioritySelector(
                new Decorator(ret => Me.IsDead || Me.IsGhost || Me.IsCasting || Me.IsChanneling || Me.IsFlying, new ActionAlwaysSucceed())
            );
        }

        public static Composite PaladinCombat()
        {
            return new PrioritySelector(
                new Decorator(ret => true, Gladiator())
                //new Decorator(ret => SpellManager.HasSpell("Shield Slam") && Buff["Gladiator Stance"].Down, Protection())
                );
        }

        public static Composite Retribution()
        {
            return new PrioritySelector(

                Cast("Bloodbath", ret => true),
                Cast("Avatar", ret => true),
                Cast("Berserker Rage", ret => Buff["Enrage"].Down),
                Cast("Shield Charge", ret => (!Buff["Shield Charge"].Up&&Cooldown["Shield Slam"].Remains < 0.1)||Spell["Shield Charge"].Charges == 2),
                Cast("Heroic Strike", ret => ((Buff["Shield Charge"].Up||Buff["Unyielding Strikes"].Up)&&Target.Health.Percent>20)||Buff["Ultimatum"].Up&&Rage>=100||Buff["Unyielding Strikes"].Stack>4),
                new Decorator(ret => ActiveEnemies == 1, Gladiator_ST()),
                new Decorator(ret => ActiveEnemies >= 2, Gladiator_AOE())
            );
        }

        public static Composite ProtectionPaladin()
        {
            return new PrioritySelector(

              Cast("Bloodbath", ret => true),
              Cast("Avatar", ret => true),
              Cast("Berserker Rage", ret => Buff["Enrage"].Down),
              Cast("Heroic Strike", ret => ((Buff["Shield Charge"].Up || Buff["Unyielding Strikes"].Up) && Target.Health.Percent > 20) || Buff["Ultimatum"].Up && Rage >= 100 || Buff["Unyielding Strikes"].Stack > 4),
              new Decorator(ret => ActiveEnemies == 1, Gladiator_ST()),
              new Decorator(ret => ActiveEnemies >= 2, Gladiator_AOE())
          );          
        }

/*actions.single=divine_storm,if=buff.divine_crusader.react&holy_power=5&buff.final_verdict.up
actions.single+=/divine_storm,if=buff.divine_crusader.react&holy_power=5&active_enemies=2&!talent.final_verdict.enabled
actions.single+=/divine_storm,if=holy_power=5&active_enemies=2&buff.final_verdict.up
actions.single+=/divine_storm,if=buff.divine_crusader.react&holy_power=5&(talent.seraphim.enabled&cooldown.seraphim.remains<=4)
actions.single+=/templars_verdict,if=holy_power=5|buff.holy_avenger.up&holy_power>=3&(!talent.seraphim.enabled|cooldown.seraphim.remains>4)
actions.single+=/templars_verdict,if=buff.divine_purpose.react&buff.divine_purpose.remains<4
actions.single+=/divine_storm,if=buff.divine_crusader.react&buff.divine_crusader.remains<4&!talent.final_verdict.enabled
actions.single+=/final_verdict,if=holy_power=5|buff.holy_avenger.up&holy_power>=3
actions.single+=/final_verdict,if=buff.divine_purpose.react&buff.divine_purpose.remains<4
actions.single+=/hammer_of_wrath
actions.single+=/judgment,if=talent.empowered_seals.enabled&((seal.truth&buff.maraads_truth.remains<cooldown.judgment.duration*2)|(seal.righteousness&buff.liadrins_righteousness.remains<cooldown.judgment.duration*2))
actions.single+=/exorcism,if=buff.blazing_contempt.up&holy_power<=2&buff.holy_avenger.down
actions.single+=/seal_of_truth,if=talent.empowered_seals.enabled&buff.maraads_truth.remains<(cooldown.judgment.duration)&buff.maraads_truth.remains<=3
actions.single+=/divine_storm,if=buff.divine_crusader.react&buff.final_verdict.up&(buff.avenging_wrath.up|target.health.pct<35)
actions.single+=/final_verdict,if=buff.divine_purpose.react|target.health.pct<35
actions.single+=/templars_verdict,if=buff.avenging_wrath.up|target.health.pct<35&(!talent.seraphim.enabled|cooldown.seraphim.remains>4)
actions.single+=/crusader_strike
actions.single+=/divine_storm,if=buff.divine_crusader.react&(buff.avenging_wrath.up|target.health.pct<35)&!talent.final_verdict.enabled
actions.single+=/divine_storm,if=buff.divine_crusader.react&buff.final_verdict.up
actions.single+=/final_verdict
actions.single+=/seal_of_righteousness,if=talent.empowered_seals.enabled&buff.liadrins_righteousness.remains<(cooldown.judgment.duration)&buff.liadrins_righteousness.remains<=3
actions.single+=/judgment
actions.single+=/templars_verdict,if=buff.divine_purpose.react
actions.single+=/divine_storm,if=buff.divine_crusader.react&!talent.final_verdict.enabled
actions.single+=/templars_verdict,if=holy_power>=4&(!talent.seraphim.enabled|cooldown.seraphim.remains>4)
actions.single+=/exorcism
actions.single+=/templars_verdict,if=holy_power>=3&(!talent.seraphim.enabled|cooldown.seraphim.remains>4)
actions.single+=/holy_prism*/


        public static Composite Retribution_ST()
        {
            return new PrioritySelector(
                Cast("Shield Slam"),
                Cast("Revenge"),
                Cast("Execute", ret => Buff["Sudden Death"].Up),
                Cast("Storm Bolt"),
                Cast("Dragon Roar"),
                Cast("Execute", ret => Rage>60&&Target.Health.Percent<20),
                Cast("Victory Rush"),
                Cast("Devastate"),
               
                new ActionAlwaysFail()
            );
        }

        public static Composite Retribution_Cleave()
        {
            return new PrioritySelector(
                Cast("Revenge"),
                Cast("Shield Slam"),
                Cast("Dragon Roar", ret => (Buff["Bloodbath"].Up||Cooldown["Bloodbath"].Remains>10)||!Talent["Bloodbath"].Enabled),
                Cast("Storm Bolt", ret => (Buff["Bloodbath"].Up || Cooldown["Bloodbath"].Remains > 7) || !Talent["Bloodbath"].Enabled),
                Cast("Thunder Clap", ret => Debuff["Deep Wounds"].Remains<3||UnfriendlysMissingDebuff("Deep Wounds", 10) > 2),
                Cast("Bladestorm", ret => Buff["Shield Charge"].Down),
                Cast("Execute", ret => Buff["Sudden Death"].Up),
                Cast("Thunder Clap", ret => ActiveEnemies > 6),
                Cast("Victory Rush"),
                Cast("Devastate"),
                new ActionAlwaysFail()
            );
        }

        public static Composite Retribution_Aoe()
        {
            return new PrioritySelector(
                Cast("Revenge"),
                Cast("Shield Slam"),
                Cast("Dragon Roar", ret => (Buff["Bloodbath"].Up || Cooldown["Bloodbath"].Remains > 10) || !Talent["Bloodbath"].Enabled),
                Cast("Storm Bolt", ret => (Buff["Bloodbath"].Up || Cooldown["Bloodbath"].Remains > 7) || !Talent["Bloodbath"].Enabled),
                Cast("Thunder Clap", ret => Debuff["Deep Wounds"].Remains < 3 || UnfriendlysMissingDebuff("Deep Wounds", 10) > 2),
                Cast("Bladestorm", ret => Buff["Shield Charge"].Down),
                Cast("Execute", ret => Buff["Sudden Death"].Up),
                Cast("Thunder Clap", ret => ActiveEnemies > 6),
                Cast("Victory Rush"),
                Cast("Devastate"),
                new ActionAlwaysFail()
            );
        }

    }
}
